﻿using System.Collections;

namespace CodeAngel.Domain.Classes
{

    ///
    //NAME: IName
    //PURPOSE: Any object that implements this interface can then use the Name class.
    ///
    public interface IName
    {
        string Name { get; set; }
        bool IsKeyword { get; set; }
        bool IsEntityDef { get; }
        EntityDef EntityDef { get; }
    }


    public class Name
    {
        ///
        //NAME: New
        ///
        //public Name(IName name)
        //{
        //    this.mName = name;
        //}
        //private IName mName;


        #region "*************************************  METHODS  *****************************************"

        /////
        ////NAME: ToViewEnum
        ////PURPOSE: Identifies the name of the view enumeration for this entity.
        /////
        //public string ToViewEnum()
        //{
        //    return this.mName.Name + "View";
        //}

        /////'
        ////'NAME: ToPlural
        /////'
        //public string ToPlural()
        //{
        //    if (this.mName.Name.EndsWith("s"))
        //    {
        //        return this.mName.Name + "es";
        //    }
        //    else if (this.mName.Name.EndsWith("y"))
        //    {
        //        return this.mName.Name.Replace("y", "ies");
        //    }
        //    else
        //    {
        //        return this.mName.Name + "s";
        //    }
        //}

        ///
        //NAME: ToBackingProperty
        //PURPOSE: To return the name of this Name as the name of a property.
        ///
        //public string ToBackingProperty()
        //{
        //    return this.mName.Name + "Property";
        //}

        //public string ToBackingPropertyField()
        //{
        //    return "_" + this.mName.Name + "Property";
        //}

        /////
        ////NAME: ToClassPropertyVariable
        ////PURPOSE: To return the name of this Name as a class level variable.
        /////
        //public string ToClassPropertyVariable(bool meQualified = false)
        //{
        //    if (meQualified)
        //    {
        //        return "Me.m" + this.mName.Name + "Property";
        //    }
        //    else
        //    {
        //        return "m" + this.mName.Name + "Property";
        //    }
        //}

        ///
        //NAME: ToField
        ///
        //public string ToField()
        //{
        //    if (this.mName.IsEntityDef)
        //    {
        //        return this.mName.Name + "ID";
        //    }
        //    else
        //    {
        //        return this.mName.Name;
        //    }
        //}

        //public string ToDtoVariable()
        //{
        //    return string.Format("This{0}DTO", this.mName.Name);
        //}

        //Public Function ToX() As String
        //    If Me.mName.IsEntityDef Then
        //        Return Me.mName.Name & "ID"
        //    Else
        //        Return Me.ToName
        //    End If
        //End Function

        ///
        //NAME: ToFieldVariable
        ///
        //public string ToFieldVariable(bool meQualified = false)
        //{
        //    string FieldVariable = null;
        //    if (this.mName.IsEntityDef)
        //    {
        //        FieldVariable = "m" + this.mName.Name + "ID";
        //    }
        //    else
        //    {
        //        FieldVariable = "m" + this.mName.Name;
        //    }
        //    if (meQualified)
        //        FieldVariable = "Me." + FieldVariable;

        //    return FieldVariable;
        //}

        ///
        //NAME: ToColumn
        ///
        //public string ToColumn()
        //{
        //    return this.mName.Name + (this.mName.IsEntityDef ? "ID" : "") + "Column";
        //}

        ///
        //NAME: ToCriterion
        ///
        //public string ToCriterion()
        //{
        //    if (this.mName.IsEntityDef)
        //    {
        //        return this.mName.Name + "ID";
        //    }
        //    else
        //    {
        //        return this.mName.Name;
        //    }
        //    //Return Me.mName.Name & IIf(Me.mName.IsEntityDef, "ID", "")
        //}

        ///
        //NAME: ToConstant
        //PURPOSE: To return the name of this property in the constant format - the constant format 
        //is all upper case with the words separated by underscore characters.
        ///
        //public string ToConstant()
        //{

        //    //Pull each word of the name out.  (This is identified by an upper case character.)
        //    ArrayList Words = new ArrayList();
        //    System.Text.StringBuilder WordBuilder = new System.Text.StringBuilder();
        //    char ThisChar = '\0';
        //    foreach (char ThisChar_loopVariable in this.mName.Name)
        //    {
        //        ThisChar = ThisChar_loopVariable;
        //        if (char.IsUpper(ThisChar))
        //        {
        //            if (WordBuilder.IsSomething()) Words.Add(WordBuilder.ToString());
        //            WordBuilder = new System.Text.StringBuilder();
        //        }
        //        WordBuilder.Append(ThisChar);
        //    }
        //    Words.Add(WordBuilder.ToString());

        //    //Put the words in uppper case and separate them by the underscore character i.e. our 
        //    //constant format.
        //    string ConstantFormat = "";
        //    string ThisWord = null;
        //    foreach (string ThisWord_loopVariable in Words)
        //    {
        //        ThisWord = ThisWord_loopVariable;
        //        if (ConstantFormat.Length == 0)
        //        {
        //            ConstantFormat += ThisWord.ToUpper();
        //        }
        //        else
        //        {
        //            ConstantFormat += "_" + ThisWord.ToUpper();
        //        }
        //    }

        //    return ConstantFormat;

        //}

        #endregion

    }
}
